#ifndef __WS2812_H__
#define __WS2812_H__

#include <stdint.h>

#define WS2812_CODE_ONE_DUTY 77  // 66
#define WS2812_CODE_ZERO_DUTY 24 // 21

typedef struct
{
    uint8_t g;
    uint8_t r;
    uint8_t b;
} rgb_t;

typedef struct ws2812_s
{
    uint8_t led_num;
    rgb_t *leds;
    uint8_t (*send)(uint8_t num, rgb_t *leds);
} ws2812_t;

uint8_t ws2812_init(ws2812_t *handle, uint8_t num, rgb_t *leds,
                    uint8_t (*send)(uint8_t num, rgb_t *leds));
uint8_t ws2812_send(ws2812_t *handle);
uint8_t ws2812_set_color(ws2812_t *handle, uint8_t index, uint8_t r, uint8_t g, uint8_t b);
uint8_t ws2812_set_color_all(ws2812_t *handle, uint8_t r, uint8_t g, uint8_t b);

#endif
